package com.ptszyxx.popose.module.main.fish.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder;
import com.ptszyxx.popose.R;
import com.ptszyxx.popose.common.utils.YVipUtil;
import com.ptszyxx.popose.databinding.ItemFishBinding;
import com.ptszyxx.popose.module.main.fish.vm.FishVM;
import com.ysg.http.data.entity.home.HomeResult;
import com.ysg.utils.YImageUtil;
import com.ysg.utils.YUserUtil;

public class FishAdapter extends BaseQuickAdapter<HomeResult, BaseDataBindingHolder<ItemFishBinding>> {

    private FishVM viewModel;
    private Presenter mPresenter = new Presenter();


    public FishAdapter(FishVM viewModel) {
        super(R.layout.item_fish);
        this.viewModel = viewModel;
    }

    @Override
    protected void convert(BaseDataBindingHolder<ItemFishBinding> holder, HomeResult item) {
        ItemFishBinding binding = holder.getDataBinding();
        if (binding != null) {
            binding.setEntity(item);
            binding.setViewModel(viewModel);
            binding.setPresenter(mPresenter);
            binding.executePendingBindings();

            if (!YVipUtil.isVip(getContext(), false)){
                YImageUtil.showBlur(binding.ivAvatar, item.getUsericon());
            }
        }
    }

    public static class Presenter{
        public void onItemClick(FishVM viewModel, HomeResult entity){
            viewModel.onItemClick(entity);
        }
    }





}
